package com.tjsinfo.tjsoa.system.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.tjsinfo.tjsoa.system.bo.ISystemPostBO;
import com.tjsinfo.tjsoa.system.vo.TSystemPost;
/**
 * 更新岗位表单
 * @author 岳晓磊
 *
 */
public class UpdatePostAction extends Action {
	private ISystemPostBO systemPostBo; 
	public void setSystemPostBo(ISystemPostBO systemPostBo) {
		this.systemPostBo = systemPostBo;
	}
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		// TODO Auto-generated method stub
		try {
			String postId = request.getParameter("postId");
			String postName = request.getParameter("postName");
			String postDes = request.getParameter("postDes");
			TSystemPost tsp = systemPostBo.findById(postId);
			tsp.setPostName(postName);
			tsp.setPostDescription(postDes);
			systemPostBo.update(tsp);
			request.setAttribute("linkurl", "system/post/postlist.jsp?fanhui=true");
			request.setAttribute("message", "system.postUpdate.message");
			return mapping.findForward("success");
		} catch (RuntimeException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			request.setAttribute("Exception", e);
			return mapping.findForward("failed");
		}
	}
}
